package com.ayitubie.refuelweb.entity;

import com.ayitubie.refuelweb.validation.group.Groups;
import com.ayitubie.refuelweb.validation.validator.ListValue;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import java.io.Serializable;

import javax.validation.constraints.NotBlank;
import java.util.Date;

@Data
@Document(indexName = "log", shards = 1, replicas = 0)
public class RefuelLog implements Serializable{
    @Id
    private Long refuel_id;
    private int refuel_station_id;
    private float avg_kilo;
    @Field(type = FieldType.Text, analyzer = "ik_smart")//"ik_max_word")
    private String station_name;
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String station_address;
    @Field(type = FieldType.Keyword)
    @ListValue( message = "油号只能是92，95，98" , vals = {"92","95","98"} , groups = {Groups.Add.class , Groups.Update.class})
    private String oil_type;
    @Field(type = FieldType.Keyword)
    private float liters;
    private String pay_type;
    @Field(type = FieldType.Keyword)
    private float pay_money;
    private Date refuel_time;
    private float mileage;
    @Field(type = FieldType.Text,index = false,docValues = false)
    @NotBlank(message="请上传图片！",groups = Groups.Add.class)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String photo;
    @Field(type = FieldType.Text,index = false,docValues = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String imageUrl;
    private int userId;
    private float pre_mileage;
}
